package cn.edu.nju.software.zp13.assignment5.service.soapMessage;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.SOAPException;

import org.w3c.dom.Document;

import cn.edu.nju.software.zp13.client.assignment4.sax.xmlNodeEntity.CourseScoreList;

public class CourseScoreListSOAPMsgProducer extends SOAPMsgProducer {
	private CourseScoreList csl;
	private Document dom;

	public CourseScoreListSOAPMsgProducer(CourseScoreList csl) {
		super();
		this.csl = csl;
		try {
			this.dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		}
		dom.appendChild(this.csl.toXmlNode(dom));
	}

	@Override
	public void processSOAPMsg() {
		try {
			soapMessage.getSOAPPart().getEnvelope().getBody().addDocument(this.dom);
		} catch (SOAPException e) {
			e.printStackTrace();
		}
	}

}
